Central Article

Creating Your First Macromedia Central Application

Phillip Kerman

phillipkerman.com

Macromedia Central offers a real opportunity for developers and a great experience for users. Even the first generation of Central applications are pretty handy. There's a lot to like in Central. For me, the fact that it's all just ActionScript means I can start making Central applications after only a modest learning curve.

This article gets your hands dirty building your first Central application. It won't be particularly pretty but with the skeleton you build here you'll be able to flex your Flash muscles to turn it into something really great. Just wait and see.

Requirements

To complete this tutorial you will need to install the following software and files:

Macromedia Central

Install Central now (free) ›

Macromedia Central SDK

Download it now ›

Macromedia Flash MX 2004


Download sample files for this tutorial


Structure and Terms Before Getting Started

Your Central product can include an application that appears in the main shell plus smaller Flash applications, called pods, that appear in the Console. Additionally, if you want to run background tasks while your application is dormant, you need an agent. Each piece of your product (application, pod, and agent) uses a separate SWF, which your users install in one click using the installer.swf file posted on your website or through Central's built-in Application Finder. In either case, you need a product.xml file, which specifies which files get installed as well as other details, such as where help files are located, the cost of your application, and the duration of any trial period, where appropriate.

Dealing with all these files really isn't so bad. For example, you can use the generic installer.swf that ships with the Central SDK as is. It automatically reads and parses product.xml. Here are the files you'll build in this tutorial (see Figure 1):

  • product.xml: Includes details needed for Central to install your files
  • installer.swf: Generic installer that parses data in product.xml
  • app.swf, app.fla, app.as: SWF and source files (.fla and .as) for the main shell application
  • pod.swf, pod.fla, pod.as: SWF and source files for the pod application
  • agent.swf, agent.fla, agent.as: SWF and source files for the agent application
  • interface.as: Provides a list of shared methods (through LCService) for all three applications

Note: For more information about LCService, read Ethan Malasky's article, "Understanding and Using the LCService Library."

Files necessary for creating your first Macromedia Central application

Figure 1. Files necessary for creating your first Macromedia Central application

You must install Central applications from an actual web server. This way, the Flash Player security restrictions will be based on the server from which you installed the Central application. For testing, you can use localhost (http://127.0.0.1). Alternatively, upload files to a website you control and install the application from there. In addition, be sure to use the Macromedia Central Product ID Registration generator so you get a unique number that ensures all your products (even tests) install properly. When you are ready to publish your application and intend to sell it, look into the requirements so you can get it listed in the Application Finder. This way your potential customers will have an easy way of finding your application. Don't worry about that for this tutorial, however, because you're just making a simple application.

Creating a Simple Central Application

To make the "simplest Central app in history" you create a FLA (app.fla) that turns into app.swf. Install the application using a generic version of installer.swf and product.xml, which basically says "install the app.swf file." For modularity purposes, app.fla includes your code inside app.as. Once you have this application running inside Central you can easily add more features.

Here are the steps:

  1. To make app.fla, open Macromedia Flash MX 2004 or Macromedia Flash MX Professional 2004 and create a new Flash document.
  2. Access Publish Settings (File > Publish Settings), select the Formats tab, and uncheck the HTML option. Select the Flash tab, change the Version drop-down list to Flash Player 6, and click OK. (You can leave ActionScript 2.0 selected.)
  3. Place the following code into the first frame of this movie (there's no semicolon at the end):

    #include "app.as"

  4. From the Components panel, drag a TextArea component to the Stage. Use the Free Transform tool to resize the TextArea. With the TextArea still selected, use the Properties panel to give the component an instance name ta. Save this file as app.fla.
  5. Create a new ActionScript file using Flash MX Professional 2004 (or just Notepad or a similar text editor). Save the file as app.as, adjacent to app.fla.
  6. Type the following code:

    	onActivate = function(shell, appID, shellID, baseTabIndex, appData) {
    		gShell=shell;
    		var myString="";
    		myString += "shell=" +        shell        +newline;
    		myString += "id=" +           appID        +newline;
    		myString += "shellID=" +      shellID      +newline;
    		myString += "baseTabIndex=" + baseTabIndex +newline;
    		myString += "appData=" +      appData;
    		ta.text = myString;
    	}
    	Central.initApplication(this, this);
    	

    All you really need to turn a Flash app into a Central app is the initApplication() method. The first parameter (this) refers to what movie is getting initialized and the second parameter (this) refers to where the onActivate() method (and other handlers) can be found. When Central has fully loaded your application it attempts to trigger the onActivate() method in your movie. Provided you write an onActivate() method it's where you can begin to perform Central features. This example just takes the parameters received and puts them in the ta TextArea instance.

    Invariably, the one thing you'll always do is save into a variable that first parameter. Even though the example above doesn't use gShell, it's a reference to the window managing your app and your key to triggering any methods in the Shell object. (That is, you can use gShell.isConnected() to determine the user's connection status.) The first parameter in any onActivate()method gives applications, pods, and agents a reference to their appropriate host (the shell, Console, or—in the case of agents—the Agent Manager).

  7. Save app.as, return to app.fla, and publish app.swf (press Shift-F12).
  8. Place app.swf along with the downloaded files product.xml and installer.swf in a test folder on your server. For example, with the default ColdFusion MX installation I use the following folder:

    C:\CFusionMX\wwwroot\myFirstCentral\

  9. Run installer.swf (not by double-clicking it) from a web browser pointing to the server—in my case:

    http://127.0.0.1:8500/myFirstCentral/installer.swf

    The ":8500" is there because I have ColdFusion listening to port 8500.

  10. Click Install Now. If you don't have Central installed, it'll be installed automatically.

Note: If you have problems with this portion, you can find the completed files in the folder "part1_finished—Creating a Simple Central Application."

This application doesn't do much more than show that it's working (see Figure 2). The five arguments received include handles on the application itself and initial values such as the starting tab index. For now, just realize that any Flash application can become a Central application by just adding the initApplication() trigger.

Although it's not much to look at, the application is now running inside Central.

Figure 2. Although it's not much to look at, the application is now running inside Central.

Updating Your Central Application

Whether you add features or fix bugs, you'll want to test the results inside Central. However, you don't have to uninstall and reinstall your application every time you make a change. Instead, you can "update" the version number of your application (which notifies users that a newer version is available for installation) or "overwrite" it, which means just manually writing over the cached files in your Central directory.

I cover overwriting later because it's more of a production tip. In addition, overwriting only works when the list of product files doesn't change. Below I show you how to add a pod to your product. To install the new files, just change the version number in product.xml.

  1. Create a new file, just as you did in the previous section (publish settings to Flash Player 6, uncheck the HTML format, and add a TextArea instance named ta). In this case, use the following code:

    #include "pod.as"

  2. Change the document properties (press Ctrl-J) to 170 x 160 pixels.
  3. Save this file as pod.fla.
  4. Create a new ActionScript file with Flash MX Professional 2004 and save the file as pod.as, adjacent to pod.fla.
  5. Type the following code:

    	onActivate = function(console, podID, viewerID, position, baseTabIndex, data) {
    		gShell=shell;
    		var myString="";
    		myString += "console=" +      console      +newline;
    		myString += "podID=" +        podID        +newline; 
    		myString += "viewerID=" +     viewerID     +newline;
    		myString += "position=" +     position     +newline;
    		myString += "baseTabIndex=" + baseTabIndex +newline;
    		myString += "appData=" +      appData;
    		ta.text = myString;
    	}
    	Central.initPod(this, this);

    This code should look familiar. The only difference from the app.as file you created earlier is that you initialize with initPod(), not initApplication(), and the parameters received include position, an integer that matches the slot into which your pod appears. All new pods appear in the zero slot (the uppermost position) but get pushed down as newer ones appear or as the user rearranges them.

    You're still saving a reference to the window that holds this application—although in this case, it's the Console that hosts the pod, not the shell hosting an application. It's still the first parameter received, however. I use gShell again just as a matter of convention. Later in the application you can use gShell to access anything in the Console object (say, gShell.loadApplication() to launch the application portion of this product).

  6. Save pod.as, return to pod.fla, and publish pod.swf (press Shift-F12).
  7. Open product.xml to add the pod and increment the version number. Specifically, change this line:

    version="1.0"

    so it reads:

    version="1.1"

    Also change this line:

    <!--<pod name="Sample Pod" src="pod.swf" height="160"/>-->

    so it reads:

    <pod name="Sample Pod" src="pod.swf" height="160"/>

  8. Save product.xml.
  9. Place pod.swf adjacent to product.xml and the rest of your product files—that is, the same location from which you installed the application earlier.
  10. Quit and relaunch Central and open the application. Select Check for Update from the My First App menu and click OK in the dialog box that appears (shown in Figure 3). When complete, choose View > Console and select My First App from the Pods menu in the Console to see your new pod.
After checking for updates, Central gives you the opportunity to upgrade the application.

Figure 3. After checking for updates, Central gives you the opportunity to upgrade the application.

Note: If you have problems with this portion, the completed files are in the folder "part2_finished--Updating Your Central Application."

Making a pod is not much different than making a regular application. Naturally, it's a smaller version of it. Any single application can have several pods. (Additional pods appear in a secondary drop-down list within the pod because your application only appears once in the Console.)

In addition to showing the similarities between pods and applications, this exercise demonstrates how easily you can update your application. There is no need to reinstall it; you just update it. As you work you may not even want to go through this simple process for every little change. In that case, you can just change the publish destination in Flash (see Figure 4) so that exported SWFs overwrite the files in Central's cache. This works only for files that are already present. In the exercise above you adjusted product.xml to include the pod. Now that the pod is part of your installed application you can update the pod by simply overwriting it. Naturally, you have to close and reopen your application or pod to see the changes appear.

By changing the target publish folder in Flash you can update your application files while testing. Just point to the cache folder in Central.

Figure 4. By changing the target publish folder in Flash you can update your application files while testing. Just point to the cache folder in Central.

Incidentally, you can overwrite agents too. However, because agents won't stop running when you switch applications, you need to restart Central for your changes to the agent to become noticeable. I cover agents next.

Creating an Agent

Your Central product can include several applications. (You might call the product a "suite" in that case.) For each application you can have multiple pods; in fact, after users install the application you can add the pods dynamically—without their intervention. Besides pods, your application can include up to one agent.

An agent is a SWF that's never seen. However, you can set your agent to start every time that Central does. This means code continues executing even when your application is closed and Central is minimized. Agents are useful for performing background tasks such as checking current weather conditions. When the temperature drops, for example, you could inform the user through a notice that behaves almost like an instant message. Not only are agents good for behind-the-scenes work but they're the logical place to store code that's common to your application and pods. This way it's available anytime the application needs it.

Sometimes commands are only available to pods, such as loadApplication(). Other times only applications can trigger them, such as requestPayment(). Generally, the agent—and its "shell" the Agent Manager—is the common denominator: It runs constantly and most commands are available there.

The ways that your application, pods, and agent talk to Central is through their respective managing objects: Shell, Console, and Agent Manager. You can see in Table 1 that most of the methods are available for all three objects. That is, you can put code where you want. However, some methods don't apply to certain situations. For example, a pod doesn't need to use isConsoleOpen() to find out whether the Console is open because the Console must be open in the first place for the pod to find out. There are other logical restrictions where one object doesn't support a particular method, but methods are available where you need them. For the most part it's up to you whether you trigger a method from your application, agent, or pod(s).

Table 1. Methods Supported by Agent Manager, Shell, and Pod
Methods Agent Manager Shell Pod
Notices      
addNotice Yes Yes Yes
getNotices Yes Yes Yes
removeNotice Yes Yes Yes
Local Internet Cache      
addToLocalInternetCache Yes Yes Yes
inLocalInternetCache Yes Yes Yes
removeFromInternetCache Yes Yes Yes
Information      
isConsoleOpen Yes Yes No
isConnected Yes Yes Yes
getPreferences Yes Yes Yes
getHeight No No Yes
getLastTabIndex No No Yes
Pod Management      
getPods Yes Yes Yes
addPod Yes Yes Yes
viewPod Yes Yes Yes
removePod Yes Yes Yes
getViewedPods Yes Yes Yes
Application Management      
getViewedApplications Yes Yes Yes
loadApplication No No Yes
Agent Management      
startAgent No Yes Yes
stopAgent Yes Yes Yes
getAgent No Yes Yes
Miscellaneous      
editLocationDialog No Yes Yes
newLocationDialog No Yes Yes
requestSizeChange No Yes No
validateActivationKey No Yes No
requestPayment No Yes No
getBounds No Yes No
getSelectedItem No Yes No
setProgress No Yes No
setStatus No Yes No
isPurchased No Yes No

While it's impossible to put all your code in the agent, you should definitely try to keep most common elements here. Ultimately, you need to send messages among your agent, pod, and application. The channel over which the pieces communicate is the Local Connection object. You can use the existing version in Macromedia Flash, but Macromedia Central has a much more eloquent version called LCService. This class not only simplifies managing multiple connections (say, many pods and application instances) but, because it's synchronous, you can set up methods that return values. I use it next to let your application and pods trigger code in the agent, as well as let the agent trigger code in the application and pods.

Note: Just in case you're thinking of using local shared objects to make the different pieces of your product communicate with each other, don't. You'll run into problems if two files attempt to read and write at the same time. Besides, the LCService class makes this task very easy. For more information about LCService, read Ethan Malasky's article, "Understanding and Using the LCService Library."

In the next exercise I show you that adding an agent is nearly the same as making the application or pod. The key is to select the appropriate tasks for your agent to perform. Generally speaking, this includes tasks you want to execute independently of whether the user is actively running your application or pod. In your agent, for example, you could use setInterval() to trigger a function that accesses a web service every 10 minutes and finds out the current temperature in the user's city. Of course, the user would need to use either a pod or application as an interface to set their city. Similarly, if the agent reports the results it gathers it needs to send that information to a pod, application, or—perhaps—a notice. Agents don't start and stop as your application is opened and closed. Therefore, carefully deciding what tasks your agent executes (anytime Central is open) is both an opportunity and a responsibility.

The basic idea behind LCService is that you want "clients" (the pods and application) to access methods in the "server" (the agent). Conversely, the agent should have access to methods in the pods and application. Because it's all handled synchronously, the pods, application, and agent can trigger—and get values returned—from any method in your product. You just need to specify which methods to expose to the LCService. The following steps show you how to define the methods in a file called interface.as:

  1. Create a new ActionScript file in Flash MX Professional 2004 or in a text editor. Save the file as interface.as. Insert the following code:

    	myInterface=new Object();
    	myInterface.name="myInterfaceName";
    	myInterface.interfaces=new Object();
    	myInterface.interfaces.Client=["tellEveryone"];
    	myInterface.interfaces.Server=["agentMethod", "forwardMethod"];
    	

    Here's the simple way to read this code: We're planning to have one method in the application and pods (tellEveryone) and two methods in the agent (agentMethod and forwardMethod). The LCService class uses a client/server metaphor where the agent is the server and the pods and application are the client. Each file in your product needs the same interface definition—which will be easy to include now that you have a separate file (interface.as).

  2. Create a new file, as you did in the earlier exercises. This time don't bother with anything on the Stage because the agent is never visible. Just set the publish settings to Flash Player 6 and uncheck the HTML format.

    Also, put this code in the first frame:

    #include "interface.as"
    #include "agent.as"

  3. Save this file as agent.fla.
  4. Create a new ActionScript file and save it as agent.as, adjacent to agent.fla.
  5. Type the following code:

    	1  owner=this;
    	2  agentMethod=function(param){
    	3    return "I heard "+param;
    	4  }
    	5  forwardMethod=function(param){
    	6    myService.tellEveryone(param);
    	7  }
    	8  onActivate = function(agentManager, agentID, data) {
    	9    gShell=agentManager;
    	10   myService=Central.LCService.createServer(myInterface, owner, true);
    	11}
    	12 Central.initAgent (this, this);
    	

    The onActivate() and initAgent() methods should look familiar. The main thing in onActivate() is creating a server instance of the LCService class. The myService variable is the way the agent triggers code in the pod or application (as on line 6). The createServer() method specifies the myInterface variable (defined in the interface.as file) and passes a reference to the place where server methods will be found (this timeline) and opt for the synchronous behavior (in the true parameter).

    Also, recall from interface.as that the two methods (agentMethod and forwardMethod) are exposed to the clients—that is, the pod and application. Just as how line 6 accesses the tellEveryone() method (to be defined in the application and pod) using a reference to the LCService, the pod and application similarly access agentMethod() and forwardMethod().

  6. Save agent.as, return to agent.fla, and publish agent.swf (press Shift-F12).
  7. Open product.xml in order to add the pod and increment the version number. Specifically, change this line:

    version="1.1"

    so it reads:

    version="1.2"

    Also change this line:

    <!--<agent name="Sample Agent" src="agent.swf" started="true"/>-->

    so it reads:

    <agent name="Sample Agent" src="agent.swf" started="true"/>

  8. Save product.xml.

Notice that the started attribute means that this agent launches as soon as Central does. (Otherwise you have to start it with the startAgent() command.)

Before you actually update the application, first update the pod and application files so that they use the agent:

  1. Open pod.as and replace all the code with the following:

    	owner=this;
    	tellEveryone=function(param){
    		ta.text+=param+newline;
    	}
    	onActivate = function(console, podID, viewerID, position, baseTabIndex, data) {
    		gShell=console; 
    		var uniqueID = podID+"_"+viewerID;
    	
    		myService=Central.LCService.createClient(myInterface, uniqueID, owner, true);
    	
    	}
    	Central.initPod(this, this);
    	

    In this case we're creating a client version of the LCService class, saved in the myService variable. Like the createServer() method, createClient() needs the variable containing the interface (myInterface—which gets defined in interface.as) and object where the methods will reside (owner, that is this timeline) and whether you want it to behave synchronously (true). The second parameter sent (uniqueID), however, is a unique string to prevent clients from conflicting. It’s not needed with createServer() because there can be only one "server."

    The tellEveryone() function is simply the pod's implementation of this method. That is, the application has the same method but it executes different code. Finally, although the application triggers the agent's forwardMethod(), coming up in Step 4 below, nowhere does the pod itself access either of the two agent's methods.

  2. Save pod.as and open pod.fla. Edit the script to read as follows:

    #include "interface.as"
    #include "pod.as"

  3. Export it to create pod.swf.
  4. Open app.as and change the code to read as follows:

    	owner=this;
    	tellEveryone=function(param){
    		ta.text+=param+newline;
    		gShell.setStatus(param);
    	}
    	echo_btn.onPress=function(){
    		ta.text+=myService.agentMethod(input_txt.text);
    	}
    	send_btn.onPress=function(){
    		myService.forwardMethod(input_txt.text);
    	}
    	onActivate = function(shell, appID, shellID, baseTabIndex, data) {
    		gShell=shell; 
    		var uniqueID = appID+"_"+shellID;
    	
    		myService=Central.LCService.createClient(myInterface, uniqueID, owner, true);
    	
    	}
    	Central.initApplication(this, this);

    This is just a bit more than the pod's code. Notice that the implementation of tellEveryone is slightly different than the pod's version. (Here you change the text in the shell's status bar.) There are also two button instances in the movie (echo_btn and send_btn) plus a text field instance (input_txt). The echo button just proves that you can call a method in the agent and get a return value. The send button is a bit simpler: It just passes data to the agent, although the agent turns around and sends that data back through the tellEveryone method. (In the last part of this tutorial you modify the agent's forwardMethod so that it looks up the current temperature for a ZIP code that you send it using this button.)

  5. Return to app.fla and modify the code to read as follows:

    #include "interface.as"
    #include "app.as"

  6. Before you publish, place two buttons on the Stage (instance names echo_btn and send_btn) and one input text field (named input_txt). Then publish it to create app.swf.
  7. Test it out! Launch the application, check for updates, and install the new version. Be sure the pod is open and try typing into the input text field and clicking either button. The send_btn passes the string to the agent, which then sends it back to both the pod and application (with the application also changing the status text area). The echo_btn simply gets a value back from the agent and places it into the TextArea component.

    Note: If you have problems with this portion, the completed files are in the folder "part3_finished--Creating an Agent.".

Turning a Simple Application into Something Useful

Although the product you've developed so far is nothing more than an exercise, it's easy enough to modify so it does something more useful. Specifically, you can make the agent treat the value received in its forwardMethod as a ZIP code and look up the temperature using a web service. Without detailing everything about Central's support for SOAP, simply modify agent.as to read as follows:

	owner=this;
	agentMethod=function(param){
		return "I heard "+param;
	}
	forwardMethod=function(param){
		clearInterval(weatherInterval);
		zipCode=param;
		myService.tellEveryone("getting temperature for "+param);
		getTempFunction();
	}
	
	getTempFunction =function(){
		clearInterval(weatherInterval);
		myRequest=myWebServiceObject.getTemp(zipCode); 
		myRequest.onResult=function(theResult) {
			myService.tellEveryone(theResult);
			weatherInterval=setInterval(getTempFunction,5000)
		}
		myRequest.onFault=function(theFault) {
			tellEveryone("error "+theFault.faultstring);
		}
	}
	onActivate = function(agentManager, agentID, data) {
		gShell=agentManager;
		myService=Central.LCService.createServer(myInterface, owner, true);
		myWSDLUri=
	"http://www.xmethods.net/sd/2001/TemperatureService.wsdl";
		myWebServiceObject = new WebService(myWSDLUri);
	}
	onDeactivate = function(){
		clearInterval(weatherInterval);
	}
	Central.initAgent (this, this);
	

Obviously, there's more code in this example. But the LCService and two methods exposed to the clients (agentMethod and forwardMethod) are still there. The forwardMethod is updated to trigger the custom function getTempFunction(). There, a web service's getTemp() method is triggered and the two possible result handlers (onResult or onFault) are defined to pass the data back to the clients (using tellEveryone) and set up a new interval that repeats the process in five seconds. For more information about using web services in Macromedia Central, see the documentation. Notice that because you're using setInterval() there's a responsibility to use clearInterval() before beginning an new interval.

In order to see this thing run, launch the application and check for updates. When that's complete, enter a ZIP code in the main application, click the Send button, and then—every five seconds or so—see the current temperature appear in both the pod and application. Actually, you can close the application and still view the pod—even close and reopen the pod! The five-second interval is only for testing purposes. Your real application should be more conservative, perhaps checking the web service only every few minutes.

Note: If you have problems with this portion, the completed files are in the folder "part4_finished--Turning a Simple Application into Something Useful."

Where to Go from Here

This tutorial emphasizes a few habits that you'll learn to appreciate. One thing you should always do is keep the reference to the appropriate shell (gShell in all my examples). It's your key to the entire API for either the shell, Console, or Agent Manager. That is, you can talk to Central through either of them.

When Central wants to talk to your application—say, to tell you that the user is resizing the window—it looks for specific event handler functions defined right in your main movie. That is, onActivate() is how Central tells your application, pod, or agent that it's fully loaded. When you study the API for the Application, Pod, or Agent objects, realize that these are methods you put into your main movie with the expectation that, at the right time, Central triggers them. You can certainly call any of these functions yourself—it's a good way to consolidate code—but for me it was easiest to learn the API once I broke down the six main objects in this way (application, pod, and agent are managed by the shell, Console, and Agent Manager).

Although I explained the LCService earlier in the "Creating an Agent" section, it may take you a little while to appreciate it fully. Basically, it consolidates code in the agent as well as lets the agent trigger code in the pods and application (or lets the pods and application trigger code in the agent).

There are many more cool features inside Macromedia Central. Let me give you a preview of my favorites:

  • LCDataProvider is a way to declare a data provider in one place and then access and modify the data in any piece of your product. When the data changes, every file using the data (and any component displaying the data) reflects the change immediately. A data provider is basically an array full of identically formatted ActionScript objects (such as records in a database where each one has fields for first name, last name, and number). Many Flash components can subscribe to a data provider to keep themselves in perfect sync. (If you want to use traditional data providers with the Central component, be sure to instantiate them using new Central.DataProviderClass().
  • Local Internet Cache is adjacent to Central where you can force any data file to cache. This way, users can still view images (including progressive JPEGs and GIFs) later. This also includes query results—say, the results of an ASP request. There are extensive tools to check whether a file exists already, remove it, or overwrite it. By default the cache size is 20 MB but users are automatically prompted to increase this when they exceed that amount.
  • Notices are almost like little e-mail messages that appear in a common place on the Console. Users can set these so they chime when they arrive. Hopefully, developers won't send so many notices that they become spam, but they can be quite useful. For example, in my real estate application, users specify the sort of house they're looking for. Using an agent, Central periodically checks for new houses that match their profile. When one is available a notice pops up. Developers can control how long a notice stays up and also write scripts that react to users interacting with the notice.
  • Blasting is a way for one application to prepare data (usually based on what the user selects) and send it to another application, which then processes the data in its own way. This means there's a sending application and a receiving application. One application might gather stock prices, for example, and then blast those numbers to a graphing tool. This cooperative nature means your application can focus on being really good at one thing instead of trying to be an "everything app."

Setting up the sending application is different than setting up the receiving application. In either case, for two applications to pass data they need to agree on a common data type. The sending application prepares the data to send (by creating a SelectedItem object) and then sets a "selection" (using setSelection()). It's not until the user selects "Blast!" (from the highlighted Blast menu appearing at the bottom right of the shell) that the data is sent. The sending application just prepares the data and makes it available to blast. (The exception to this is when user have autoblast turned on, in which case data is sent as soon as a selection is set.)

The receiving application, in order to receive the data, first has to declare that it accepts the same data type being sent. It also defines an onSelectedItem() handler. This is the method that Central calls when data is sent.

Although your first Central application will probably fail to earn you a million dollars, you should now have a good handle on the main pieces of a Central application. Specifically, you learned the following:

  • How product.xml identifies which files get installed and easily updates existing installed components
  • How to initialize an application (and pod and agent)
  • How the onActivate() callback is where you can begin doing Central stuff, as well as where you get a reference to the appropriate shell—Shell, Console, or Agent Manager, depending on whether you're in the application, pod, or agent file, respectively
  • How the LCService class simplifies sending messages between your application pieces
  • How to set the publish directory in Flash to target the cache in Central, among other tips

About the author

Phillip Kerman is a Macromedia Flash programmer and author of the best-selling Sams Teach Yourself Macromedia Flash 24 Hours, ActionScripting in Flash, and the new book Flash MX 2004 for Rich Internet Applications. He also conducts Macromedia Flash training workshops around the world. He used Macromedia Flash Communication Server MX and Flash Remoting to program a real-time auction for www.stampedecattle.com that sells millions of dollars worth of cattle per hour. His site www.phillipkerman.com includes several Communication Server examples.